<?php
require "querylist/vendor/autoload.php";
use QL\querylist;
$data =  QueryList::get('https://www.17k.com/all')

    ->rules([

        'no_type'=>array('.bg0 .td2','text'),
        'no_name'=>array('.bg0 .td3 .jt','text'),
        'no_num'=>array('.bg0 .td5','text'),
        'no_author'=>array('.bg0 .td6','text')

])
->queryData();
$dbh = new PDO('mysql:host=127.0.0.1;dbname=1705phpa', 'root', 'root');
$dbh->exec("set names utf8");
$sql="insert into week3 (`no_type`,`no_name`,`no_num`,`no_author`) VALUES ";

foreach($data as $k=>$v)
{
    $no_type=$dbh->quote($v['no_type']);
    $no_name=$dbh->quote($v['no_name']);
    $no_num=$dbh->quote($v['no_num']);
    $no_author=$dbh->quote($v['no_author']);

    $sql.="($no_type,$no_name,$no_num,$no_author),";

}

$sql=substr($sql,0,-1);

$dbh->exec($sql);

?>